package com.example.demo.utils;

/**
 * @author xieluoyin
 */
public class H3cIotExceptionUtil {
    private H3cIotExceptionUtil() {
    }

    static void exceedsLowerLimit(String fieldName, Integer iValue, String msg, Integer min) {
        throw new H3cIotException(
                Constant.ResponseCode.PARAMETER_LENGTH_EXCEEDS_THE_LOWER_LIMIT,
                msg + fieldName + " length exceeds the lower limit!最小长度为" + min+",你的是"+iValue
        );
    }

    static void exceedsUpperLimit(String fieldName, Integer iValue, String msg, Integer max) {
        throw new H3cIotException(
                Constant.ResponseCode.PARAMETER_LENGTH_EXCEEDS_THE_UPPER_LIMIT,
                msg + fieldName + " length exceeds the upper limit!最大长度为" + max+",你的是"+iValue);
    }

    static void errorIsMinGtMax(String fieldName, String msg) {
        throw new H3cIotException(
                Constant.ResponseCode.
                        ERROR_IN_INTERNAL_LOGIC,
                "【系统内部错误】" + fieldName +
                        " 内部逻辑错误：后台设置参数的最小长度大于最大长度！");
    }
    public static void errorInAnnotationConfiguration(String fieldName) {
        throw new H3cIotException(
                Constant.ResponseCode.
                        ERROR_IN_ANNOTATION_CONFIGURATION,
                "【系统内部错误】" + fieldName +
                        " 注解错误");
    }


    static void parameterNULL(String fieldName, String msg) {
        throw new H3cIotException(
                Constant.ResponseCode.PARAMETER_IS_NULL,
                msg + fieldName + " is null!"
        );
    }

    static void parameterEMPTY(String fieldName, String msg) {
        throw new H3cIotException(
                Constant.ResponseCode.PARAMETER_IS_EMPTY,
                msg + fieldName + " is empty!"
        );
    }

    static void parameterMismatching(String fieldName, String msg, String matchingMsg) {
        throw new H3cIotException(
                Constant.ResponseCode.PARAMETER_MISMATCHING,
                msg + fieldName +
                        " 参数格式不匹配!"
                        + matchingMsg);

    }
    /*public static void urlIsEmpty(){
        throw new H3cIotException(
                Constant.ResponseCode.DEFAULT_HINT_CODE,
                "url is empty");
    }*/


}


